import Vue from 'vue'
import VueRouter from 'vue-router'
import routes from './routes'

Vue.use(VueRouter)

const router = new VueRouter({
  routes: routes
})

//  加入导航守卫，进行权限判定
router.beforeEach((to, from, next) => {
  if (!to.meta.required) {
    next()
  } else {
    console.log(from.path)
    console.log(from.fullPath)
    console.log(from.params)
    next(from.path)
  }
})

export default router
